﻿using RpcClient.Interface;
using RpcSyncService.Interface;

namespace RpcSyncService.Accredit
{
    [RpcClient.Attr.UnityName("redis")]
    [RpcClient.Attr.ClassLifetimeAttr(RpcClient.Attr.ClassLifetimeType.单例)]
    internal class RedisAccredit : IAccreditCollect
    {
        private IUnityCollect _Unity;
        public RedisAccredit(IUnityCollect unity)
        {
            this._Unity = unity;
        }

        public bool Get(Guid accreditId, out IAccreditToken token)
        {
            token = _Unity.Resolve<IAccreditToken>("redis");
            return token.Init(accreditId);
        }
        public void Accredit(AccreditToken token)
        {
            IAccreditToken accredit = _Unity.Resolve<IAccreditToken>("redis");
            accredit.Create(token);
        }
    }
}
